/***********************************************************************
 * Module:  HibernateDao.java
 * Author:  Ramon
 * Purpose: Defines common interface for Hibernate access
 ***********************************************************************/

package com.obelisco.modelo.dao.hibernate;

import java.io.Serializable;
import java.util.List;
import org.hibernate.criterion.Criterion;
import com.obelisco.modelo.dao.DAOException;

/**
 * Interface that defines common methods for Hibernate access.
 * 
 */
public interface IHibernateDAO<T> {

	public void flushSession() throws DAOException;

	public void clearSession() throws DAOException;

	public void update(Object persistentObject) throws DAOException;

	public void delete(Object persistentObject) throws DAOException;

	public List<T> queryByExample(Object persistentObject)
			throws DAOException;

	public List<T> findAll(Class<T> clazz) throws DAOException;

	public List<T> findByProperty(Class<T> clazz, Criterion restriction)
			throws DAOException;

	public List<T> findByCriterions(Class<T> clazz, List<Criterion> restrictions)
			throws DAOException;

	public List<T> findBySQLQuery(String sqlQuery, String aliasName, Class<T> clazz)
			throws DAOException;

	public List<T> findByHQLQuery(String hqlQuery) throws DAOException;

	public List<T> findByNamedParam(String queryString, String paramName,
			Object value) throws DAOException;

	public List<T> findByNamedParam(String queryString, String paramName,
			Object value, int firstResult, int maxResult) throws DAOException;

	public List<T> findByNamedParam(final String queryString,
			final String[] paramNames, final Object[] values)
			throws DAOException;

	public List<T> findByNamedParam(final String queryString,
			final String[] paramNames, final Object[] values,
			final int firstResult, final int maxResult) throws DAOException;

	public List<T> findByValueBean(final String queryString, final Object valueBean)
			throws DAOException;

	public List<T> findByNamedQuery(String queryName) throws DAOException;

	public List<T> findByNamedQuery(String queryName, Object value)
			throws DAOException;

	public List<T> findByNamedQuery(final String queryName, final Object[] values)
			throws DAOException;

	public List<T> findByNamedQueryAndNamedParam(String queryName,
			String paramName, Object value) throws DAOException;

	public List<T> findByNamedQueryAndNamedParam(final String queryName,
			final String[] paramNames, final Object[] values)
			throws DAOException;

	public List<T> findByNamedQueryAndValueBean(final String queryName,
			final Object valueBean) throws DAOException;

	public boolean isCacheQueries();

	public String getQueryCacheRegion();

	public Serializable save(Object persistentObject) throws DAOException;

	public void saveOrUpdate(Object persistentObject) throws DAOException;

	public List<T> find(String queryString, int firstResult, int maxResult)
			throws DAOException;

	public List<T> find(String queryString) throws DAOException;

	public List<T> find(String queryString, Object value) throws DAOException;

	public List<T> find(final String queryString, final Object[] values)
			throws DAOException;

	public List<T> find(final String queryString, final Object[] values,
			final int firstResult, final int maxResult) throws DAOException;

	public List<T> loadAll(final Class<T> entityClass) throws DAOException;

	public List<T> loadAll(final Class<T> entityClass, final int firstResult,
			final int maxResult) throws DAOException;
}